<?php
/***************************************************************************
 *   copyright : (C) 2009 Udrea Cristian
 *   site : http://code.google.com/p/testauction-php
 ***************************************************************************/

/***************************************************************************
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU Lesser General Public License as 
 *   published by the Free Software Foundation; either version 2 of the
 *   License, or (at your option) any later version. Although none of the
 *   code may be sold. If you have been sold this script, get a refund.
 ***************************************************************************/
class Progress extends Element{
	
	public function __construct($image, $width, $name){
		$this->attributes['Progress']=0;
		$this->attributes['Image']=$image;
		$this->attributes['ImageWidth']=$width;
		$this->attributes['Name']=$name;
	}
	
	public function setName($name){
		$this->setAttribute("Name", $name);
	}
	
	public function setProgress($progress){
		$this->setAttribute("Progress", $progress);
	}
	
	public function setTooltipText($text){
		global $tooltips;
		$tooltips->deleteTooltip("tip".$this->getAttribute("Name"));
		$tooltips->createTooltip("tip".$this->getAttribute("Name"), $text);
		$this->setOption("onmouseover", $tooltips->getTooltipEvent("tip".$this->getAttribute("Name")));
		$this->setOption("onmouseout", $tooltips->getTooltipEvent("tip".$this->getAttribute("Name")));
	}
	
	public function toString(){
		global $tooltips;
		$prog_pixels = -$this->getAttribute("ImageWidth")/2 + $this->getAttribute("Progress")*(($this->getAttribute("ImageWidth")/2)/100);
		return $tooltips->tooltipToString("tip".$this->getAttribute("Name")).$this->nl()
			."<img id=\"bar".$this->getAttribute("Name")."\" alt=\"Oferte ramase\" src=\"".$this->getAttribute("Image")
			."\" class=\"percentImage\" style=\"background-position: ".$prog_pixels."px 0pt;\"".$this->optionsToString()."/>"
			."<input type=\"hidden\" id=\"var".$this->getAttribute("Name")."\" value=\"".$this->getAttribute("Progress")."\"/>";
	}
}

$creditbar = new Progress("images/percentImage.png", 121, "OfferBallance");
?>
